<!--  -->
<template>
  <div class='outsideBox'>
    <el-button v-permissions="'device:add'" type="primary" @click="addDevice" style="margin-bottom: 10px;">新增</el-button>
    <!-- <el-button v-permissions="'device:add'" type="primary" @click="addDevice_test" style="margin-bottom: 10px;">新增</el-button> -->
    <!-- 查询 -->
    <el-form :inline="true" :model="FindFromForDevice" class="demo-form-inline">
      <el-form-item label="设备名称">
        <el-input v-model="FindFromForDevice.kw" placeholder="请输入关键字"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitSrearch">查询</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-form class="demo-form-inline">
      <el-button type="primary" @click="openFrame">设备分配</el-button>
    </el-form>
      <!-- 列表展示 -->
    <el-table
      :data="fileList"
      style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column
        type="index"
        label="序号"
        width="55">
      </el-table-column>
      <el-table-column
        prop="name"
        label="设备名称"
        width="120">
      </el-table-column>
      <el-table-column
        prop="manufacturerName"
        label="厂家名称"
        width="80">
      </el-table-column>
      <el-table-column
        label="设备类型"
        width="100">
        <template slot-scope="scope">
          <span>{{ scope.row.deviceType === 0 ? '网关' : scope.row.deviceType === 1 ? '温湿度' : scope.row.deviceType === 2 ? '开关' : scope.row.deviceType === 3 ? '土壤温湿度' : scope.row.deviceType === 4 ? '秤' : scope.row.deviceType === 5 ? '氨气' : '' }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="remark"
        label="备注"
        width="120">
      </el-table-column>
      <el-table-column
        label="创建时间"
        width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="状态"
        width="160">
        <template slot-scope="scope">
          <div v-if="scope.row.deviceType === 2">
            <el-switch
              v-model="scope.row.status"
              @change="changeStatus(scope.row)"
              active-color="#13ce66"
              inactive-color="#ff4949">
            </el-switch>
          </div>
          <div v-else>
            -
          </div>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        >
        <template slot-scope="scope">
          <el-button
            v-permissions="'device:detail'"
            @click="getDetailDevice(scope.row.id,scope.row.manufacturerId,scope.row.deviceType)"
            type="text"
            size="small">详情</el-button>
          <!-- <el-button v-permissions="'earTag:delete'" @click  ="deletLiveStockDUser(scope.row.id)" type="text" size="small">删除</el-button> -->
          <el-button v-permissions="'device:delete'" @click="deletLiveStockDUser(scope.row.id)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      class="pagination_container"
      :total="pagination_out.total"
      :page-sizes="[10, 20, 50, 100]"
      :page.sync="pagination_out.page"
      :limit.sync="pagination_out.pageSize"
      @pagination="getDeviveListing"
    />
    <!-- 新增设备 -->
    <el-dialog
      title="新增设备"
      :visible.sync="addCompany"
      @close="closeDiaAdd"
      :close-on-press-escape="true"
      :close-on-click-modal="false"
      width="50%">
      <el-form ref="formName" :model="formForAddDevice" :rules="addEarTagRule" label-width="100px">
        <el-form-item label="设备名称" prop="name">
          <el-input v-model="formForAddDevice.name"></el-input>
        </el-form-item>
        <el-form-item label="设备密钥" prop="deviceKey">
          <el-input v-model="formForAddDevice.deviceKey"></el-input>
        </el-form-item>
        <el-form-item label="设备编号" prop="deviceNum">
          <el-input v-model="formForAddDevice.deviceNum"></el-input>
        </el-form-item>
        <el-form-item label="设备类型" prop="deviceType">
            <el-select
              v-model="formForAddDevice.deviceType"
              placeholder="请选择"
              @change="changeDeviceType">
              <el-option
                v-for="(item,index) in formForAddDevice.deviceTypeArr"
                :key="index"
                :label="item.label"
                :value="item.id"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item v-show="formForAddDevice.deviceType === 2" label="开关总路数" prop="switchCount">
          <el-input type="number" v-model="formForAddDevice.switchCount" @blur="blurForSwitchCount"></el-input>
        </el-form-item>
        <el-form-item v-show="formForAddDevice.switchCount != ''" label="开关初始路数" prop="switchCount">
          <el-select
            v-model="formForAddDevice.switchInitID"
            placeholder="请选择">
            <el-option
              v-for="(item,index) in formForAddDevice.switchCountArr"
              :key="index"
              :label="item"
              :value="item"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="厂商" prop="gatewayId">
          <el-select
            v-model="formForAddDevice.gatewayId"
            placeholder="请选择"
            @change="changeGetWay">
            <el-option
              v-for="(item,index) in formForAddDevice.gateWayArr"
              :key="index"
              :label="item.mName"
              :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="网关"
          prop="gatewayId"
          v-show="isShowGateWAY">
            <el-select
              v-model="formForAddDevice.wangguanId"
              placeholder="请选择">
              <el-option
                v-for="(item,index) in formForAddDevice.wangguanArr"
                :key="index"
                :label="item.name"
                :value="item.id"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formForAddDevice.remark"></el-input>
        </el-form-item>
      </el-form>
      <div style="width: 100%; text-align: center;">
        <el-button type="primary" @click="addMyNewCompany">保存</el-button>
      </div>
    </el-dialog>
    <!-- 设备详情 -->
    <el-dialog
      title="设备详情"
      :visible.sync="deviceDetailOpen"
      @close="closeDiaDetail"
      :close-on-press-escape="true"
      :close-on-click-modal="false"
      width="50%">
      <el-form
        ref="formDetail"
        :disabled="isDisabled"
        :model="formForDetailDevice"
        :rules="DetailDeviceRules"
        label-width="100px">
        <el-form-item label="设备名称" prop="name">
          <el-input v-model="formForDetailDevice.name"></el-input>
        </el-form-item>
        <el-form-item label="设备密钥" prop="deviceKey">
          <el-input v-model="formForDetailDevice.deviceKey"></el-input>
        </el-form-item>
        <el-form-item label="设备编号" prop="deviceNum">
          <el-input v-model="formForDetailDevice.deviceNum"></el-input>
        </el-form-item>
        <el-form-item label="设备类型" prop="deviceType">
            <el-select
              v-model="formForDetailDevice.deviceType"
              placeholder="请选择"
              @change="changeDeviceDetail">
              <el-option
                v-for="(item,index) in formForDetailDevice.deviceTypeArr"
                :key="index"
                :label="item.label"
                :value="item.id"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="设备详情" v-show="isShowButtonWord && formForDetailDevice.ext !== null && formForDetailDevice.deviceType !== 2">
          <el-popover
            placement="right"
            width="400"
            v-model="visible"
            trigger="manual">
            <extCom
              :extObject="extComObj"
              :key="extComKey"
              :typeId="extComId"/>
            <span
              slot="reference"
              @click="clickVisible(formForDetailDevice.deviceType,formForDetailDevice.ext)"
              style="color: #6009eb; cursor:pointer; font-size: 12px;">点击查看</span>
          </el-popover>
        </el-form-item>
        <el-form-item v-show="formForDetailDevice.deviceType === 2" label="开关总路数" prop="switchCount">
          <el-input @blur="blurDetailC" type="number" v-model="formForDetailDevice.switchCount"></el-input>
        </el-form-item>
        <el-form-item v-show="formForDetailDevice.deviceType === 2" label="开关初始路数" prop="switchCount">
          <el-select v-model="formForDetailDevice.switchNum" placeholder="请选择">
            <el-option
              v-for="(item,index) in formForDetailDevice.switchCountArrDetail"
              :key="index"
              :label="item"
              :value="item"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="厂商" prop="gatewayId">
            <el-select
              v-model="formForDetailDevice.gatewayId"
              placeholder="请选择"
              @change="changeDetailsFactory">
              <el-option
                v-for="(item,index) in formForDetailDevice.gateWayArr"
                :key="index"
                :label="item.mName"
                :value="item.id"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item
          label="网关"
          v-show="isShowDetailGetway">
            <el-select
              v-model="formForDetailDevice.wangguanId"
              placeholder="请选择">
              <el-option
                v-for="(item,index) in formForDetailDevice.wangguanArr"
                :key="index"
                :label="item.name"
                :value="item.id"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formForDetailDevice.remark"></el-input>
        </el-form-item>
      </el-form>
      <div style="width: 100%; text-align: center;">
        <el-button v-permissions="'device:update'" type="primary" @click="setConfigUserRole" v-if="isDisabled">修改</el-button>
        <el-button v-permissions="'device:update'" type="primary" @click="submitConfigUser" v-if="!isDisabled">保存</el-button>
        <el-button type="primary" @click="closeDiaDetail">关闭</el-button>
      </div>
    </el-dialog>

    <!-- 选择设备组合的开关 -->
    <el-dialog
      title="设备组合"
      :visible.sync="isShowFrame"
      @close="closeFrame"
      append-to-body
      width="80%">
      <div class="likeBox">
        <shuttleFrame
          :key="componentKey"
          @closePopup="isShowFrame=false"
          :seeChangeCourse="seeChangeCourse"
          :tableList='getListArr'
          :pagination="pagination"/>
      </div>
    </el-dialog>
  </div>

</template>

<script>
import Pagination from '@/components/pagination'
import shuttleFrame from '@/components/shuttleFrame'
import extCom from '@/components/extCom'
import { deviceAdd, deviceList, deviceDetail, deviceUpdate, deviceGatewayList } from '@/api/device' // 设备接口
import { manufacturerAllList } from '@/api/manufacturer' // 所有厂商
// import { debounce, throttle } from '@/until/paramRou'
export default {
  // import引入的组件需要注入到对象中才能使用
  components: {
    shuttleFrame,
    Pagination,
    extCom
  },
  data () {
    // 这里存放数据
    return {
      isShowButtonWord: false,
      extComId: 0,
      extComObj: {},
      extComKey: new Date().getTime(),
      visible: false,
      getwayTag: 0,
      isShowGateWAY: false,
      // 详情
      isShowDetailGetway: false,
      isShowTagForDetail: 0,
      isDisabled: true,
      deviceDetailOpen: false,
      formForDetailDevice: {
        switchCountArrDetail: [],
        switchNum: '',
        switchCount: '',
        name: '',
        ext: {},
        deviceId: '',
        deviceNum: '',
        deviceType: '',
        num: '',
        deviceKey: '',
        wangguanId: '',
        wangguanArr: [],
        deviceTypeArr: [
          {
            id: 0,
            label: '网关'
          },
          {
            id: 1,
            label: '温湿度'
          },
          {
            id: 2,
            label: '开关'
          },
          {
            id: 3,
            label: '土壤温湿度'
          },
          {
            id: 4,
            label: '秤'
          },
          {
            id: 5,
            label: '氨气'
          }
        ],
        gatewayId: '',
        gateWayArr: [],
        remark: '',
        status: 0
      },
      DetailDeviceRules: {
        name: [
          { required: true, trigger: 'blur', message: '请输入设备名称' }
        ],
        deviceNum: [
          { required: true, trigger: 'blur', message: '请输入设备编号' }
        ],
        deviceKey: [
          { required: true, trigger: 'blur', message: '请输入设备密钥' }
        ],
        deviceType: [
          { required: true, trigger: 'change', message: '请选择设备类型' }
        ],
        gatewayId: [
          { required: true, trigger: 'change', message: '请选择厂商' }
        ]
      },
      // 新增
      formForAddDevice: {
        name: '',
        switchInitID: '',
        switchCount: '',
        deviceType: '',
        deviceNum: '',
        deviceKey: '',
        switchCountArr: [],
        deviceTypeArr: [
          {
            id: 0,
            label: '网关'
          },
          {
            id: 1,
            label: '温湿度'
          },
          {
            id: 2,
            label: '开关'
          },
          {
            id: 3,
            label: '土壤温湿度'
          },
          {
            id: 4,
            label: '秤'
          },
          {
            id: 5,
            label: '氨气'
          }
        ],
        gatewayId: '',
        gateWayArr: [],
        remark: '',
        wangguanArr: [],
        wangguanId: '',
        status: 0
      },
      addEarTagRule: {
        name: [
          { required: true, trigger: 'blur', message: '请输入设备名称' }
        ],
        deviceNum: [
          { required: true, trigger: 'blur', message: '请输入设备编号' }
        ],
        deviceKey: [
          { required: true, trigger: 'blur', message: '请输入设备密钥' }
        ],
        deviceType: [
          { required: true, trigger: 'change', message: '请选择设备类型' }
        ],
        gatewayId: [
          { required: true, trigger: 'change', message: '请选择厂商' }
        ]
      },
      addCompany: false,
      seeChangeCourse: false,
      componentKey: new Date().getTime(),
      // 查询
      FindFromForDevice: {
        kw: ''
      },

      // 分页
      pagination_out: {
        page: 1,
        pageSize: 10,
        total: 0
      },
      // indexpage List
      fileList: [],
      // components list
      getListArr: [],
      pagination: {
        page: 1,
        pageSize: 5,
        total: 0
      },
      isShowFrame: false
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {
    isShowFrame: {
      handler (newVal, oldVal) {
        if (!newVal) {
          sessionStorage.setItem('checkedRightArray', JSON.stringify([]))
        }
      },
      deep: true, // 开启深度监听
      // 可以选择性地添加 immediate: true，使得在初始化时立即执行一次 handler
      immediate: true
    }
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {
    this.getDeviveListing()
  },
  // 方法集合
  methods: {
    clickVisible (valA, valB) {
      this.extComId = parseInt(valA)
      this.extComObj = valB
      this.extComKey = new Date().getTime()
      this.visible = !this.visible
    },
    changeDetailsFactory (val) {
      this.isShowTagForDetail = this.formForDetailDevice.gateWayArr[val - 1].isGateway === 1 ? 1 : 0
      if (this.isShowTagForDetail === 1 && this.formForDetailDevice.deviceType === 2) {
        deviceGatewayList(val).then(resultData => {
          this.formForDetailDevice.wangguanArr = resultData.data
          this.isShowDetailGetway = true
        })
      } else {
        this.isShowDetailGetway = false
      }
    },
    changeDeviceDetail (val) {
      // if (condition) {

      // }
      if ((this.formForDetailDevice.gatewayId === 2 || this.isShowTagForDetail === 1) && val === 2) {
        deviceGatewayList(this.formForDetailDevice.gatewayId).then(resultData => {
          this.formForDetailDevice.wangguanArr = resultData.data
          this.isShowDetailGetway = true
        })
      } else {
        this.isShowDetailGetway = false
      }
    },
    blurDetailC () {
      this.formForDetailDevice.switchCountArrDetail = []
      for (let index = 0; index < this.formForDetailDevice.switchCount; index++) {
        this.formForDetailDevice.switchCountArrDetail.push(index + 1)
      }
    },
    blurForSwitchCount () {
      this.formForAddDevice.switchCountArr = []
      for (let index = 0; index < this.formForAddDevice.switchCount; index++) {
        this.formForAddDevice.switchCountArr.push(index + 1)
      }
    },
    changeDeviceType (val) {
      if (this.getwayTag === 1 && val === 2) {
        deviceGatewayList(this.getwayIDForAPI).then(res => {
          this.formForAddDevice.wangguanArr = res.data
          this.isShowGateWAY = true
        })
      } else {
        this.isShowGateWAY = false
      }
    },
    changeGetWay (val) {
      this.getwayTag = this.formForAddDevice.gateWayArr[val - 1].isGateway === 1 ? 1 : 0
      this.getwayIDForAPI = this.formForAddDevice.gateWayArr[val - 1].id
      if (this.formForAddDevice.gateWayArr[val - 1].isGateway === 1 && this.formForAddDevice.deviceType === 2) {
        deviceGatewayList(this.getwayIDForAPI).then(res => {
          this.formForAddDevice.wangguanArr = res.data
          this.isShowGateWAY = true
        })
      } else {
        this.isShowGateWAY = false
      }
    },
    changeStatus (val) {
      const addDevice = {
        switchCount: val.switchCount,
        deviceId: val.id,
        deviceKey: val.deviceKey,
        deviceNum: val.num,
        deviceType: val.deviceType,
        manufacturerId: val.fId,
        gatewayId: val.gatewayId,
        name: val.name,
        remark: val.remark,
        switchNum: val.switchNum,
        status: val.status = val.status === true ? 1 : 0
      }
      deviceUpdate(addDevice).then(res => {
        this.addCompany = false
        if (res.code === '200') {
          this.getDeviveListing()
          this.$message({
            message: '操作成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: res.message,
            type: 'error'
          })
        }
      })
    },
    closeDiaAdd () {
      this.addCompany = false
      this.formForAddDevice = {
        name: '',
        switchInitID: '',
        switchCount: '',
        switchCountArr: [],
        deviceType: '',
        deviceKey: '',
        deviceNum: '',
        deviceTypeArr: [
          {
            id: 0,
            label: '网关'
          },
          {
            id: 1,
            label: '温湿度'
          },
          {
            id: 2,
            label: '开关'
          },
          {
            id: 3,
            label: '土壤温湿度'
          },
          {
            id: 4,
            label: '秤'
          },
          {
            id: 5,
            label: '氨气'
          }
        ],
        gatewayId: '',
        gateWayArr: [],
        wangguanId: '',
        wangguanArr: [],
        remark: '',
        status: 0
      }
    },
    closeDiaDetail () {
      this.deviceDetailOpen = false
      this.visible = false
      this.isDisabled = true
      this.isShowDetailGetway = false
      this.isShowButtonWord = false
      this.formForDetailDevice = {
        switchCount: '',
        name: '',
        ext: {},
        deviceId: '',
        deviceNum: '',
        deviceType: '',
        num: '',
        deviceKey: '',
        deviceTypeArr: [
          {
            id: 0,
            label: '网关'
          },
          {
            id: 1,
            label: '温湿度'
          },
          {
            id: 2,
            label: '开关'
          },
          {
            id: 3,
            label: '土壤温湿度'
          },
          {
            id: 4,
            label: '秤'
          },
          {
            id: 5,
            label: '氨气'
          }
        ],
        gatewayId: '',
        gateWayArr: [],
        remark: '',
        status: 0
      }
    },
    setConfigUserRole () {
      this.$confirm('是否确认修改设备信息', '提示', {
        confirmButtonText: '确定',
        showCancelButton: '取消',
        distinguishCancelAndClose: false
      }).then(() => {
        this.isDisabled = false
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消!'
        })
      })
    },
    submitConfigUser () {
      this.$refs.formDetail.validate((valid) => {
        if (valid) {
          const addDevice = {
            switchCount: this.formForDetailDevice.switchCount,
            deviceId: this.formForDetailDevice.deviceId,
            deviceKey: this.formForDetailDevice.deviceKey,
            deviceNum: this.formForDetailDevice.deviceNum,
            deviceType: this.formForDetailDevice.deviceType,
            manufacturerId: this.formForDetailDevice.gatewayId,
            name: this.formForDetailDevice.name,
            remark: this.formForDetailDevice.remark,
            status: this.formForDetailDevice.status
          }
          console.log(this.formForDetailDevice)
          for (const key in this.formForDetailDevice) {
            if (this.formForDetailDevice[key] === null || this.formForDetailDevice[key] === '') {
              delete this.formForDetailDevice[key]
            }
          }
          console.log(this.formForDetailDevice)

          deviceUpdate(addDevice).then(res => {
            this.addCompany = false
            if (res.code === '200') {
              this.getDeviveListing()
              this.closeDiaDetail()
              this.$message({
                message: '操作成功',
                type: 'success'
              })
            } else {
              this.$message({
                message: res.message,
                type: 'error'
              })
            }
          })
        } else {
          return false
        }
      })
    },
    // 详情
    getDetailDevice (id, manufacturerId, deviceType) {
      this.deviceDetailOpen = true
      this.getManufacList()
      deviceDetail(id).then(res => {
        if (res.code === '200') {
          if (res.data.gatewayId != null) {
            this.formForDetailDevice.wangguanId = res.data.gatewayId
            deviceGatewayList(res.data.fId).then(resultData => {
              this.formForDetailDevice.wangguanArr = resultData.data
              this.isShowDetailGetway = true
            })
          }
          this.formForDetailDevice.deviceId = id
          this.formForDetailDevice.deviceNum = res.data.num
          this.formForDetailDevice.switchCount = res.data.switchCount
          this.formForDetailDevice.switchNum = res.data.switchNum
          this.formForDetailDevice.deviceKey = res.data.deviceKey
          this.formForDetailDevice.name = res.data.name
          this.formForDetailDevice.deviceType = res.data.deviceType
          this.formForDetailDevice.gatewayId = manufacturerId
          this.formForDetailDevice.remark = res.data.remark
          this.formForDetailDevice.ext = res.data.ext
          this.isShowButtonWord = true
        }
      })
    },
    // 获取厂商列表
    getManufacList () {
      manufacturerAllList().then(res => {
        if (res.code === '200') {
          this.formForAddDevice.gateWayArr = res.data
          this.formForDetailDevice.gateWayArr = res.data
        }
      })
    },
    // 新增设备
    addDevice () {
      this.getManufacList()
      this.addCompany = true
    },
    // 保存新增
    addMyNewCompany () {
      this.$refs.formName.validate((valid) => {
        if (valid) {
          const addDevice = {
            deviceType: this.formForAddDevice.deviceType,
            deviceKey: this.formForAddDevice.deviceKey,
            switchCount: this.formForAddDevice.switchCount,
            switchNum: this.formForAddDevice.switchInitID,
            deviceNum: this.formForAddDevice.deviceNum,
            manufacturerId: this.formForAddDevice.gatewayId,
            name: this.formForAddDevice.name,
            remark: this.formForAddDevice.remark,
            status: this.formForAddDevice.status,
            gatewayId: this.formForAddDevice.wangguanId
          }
          console.log(addDevice)

          deviceAdd(addDevice).then(res => {
            this.addCompany = false
            if (res.code === '200') {
              this.getDeviveListing()
              this.$message({
                message: '操作成功',
                type: 'success'
              })
            } else {
              this.$message({
                message: res.message,
                type: 'error'
              })
            }
          })
        } else {
          return false
        }
      })
    },
    openFrame () {
      this.componentKey = new Date().getTime()
      if (this.getListArr.length < 1) {
        this.$message({
          message: '请至少选择一个设备',
          type: 'warning'
        })
        return false
      }
      for (const el of this.getListArr) {
        el.ischecked = false
      }
      this.isShowFrame = true
      this.seeChangeCourse = this.isShowFrame
    },
    handleSelectionChange (val) {
      this.getListArr = val
    },
    testFun () {
      return 99999
    },
    getDeviveListing () {
      const obj = {
        kw: this.FindFromForDevice.kw,
        limit: this.pagination_out.pageSize,
        page: this.pagination_out.page
      }
      deviceList(obj).then(res => {
        if (res.code === '200') {
          for (const el of res.data.records) {
            if (el.status === 0) {
              el.status = false
            } else {
              el.status = true
            }
          }
          this.fileList = res.data.records
          if (res.data.total > 0 && Math.ceil(res.data.total / this.pagination_out.size) < this.pagination_out.page) {
            this.pagination_out.page = Math.ceil(res.data.total / this.pagination_out.size)
            this.getDeviveListing()
          } else {
            this.pagination_out.total = res.data.total
          }
        } else {
          this.$message({
            message: res.message,
            type: 'warning'
          })
        }
      })
    },
    // 查询 Fun
    submitSrearch () {
      this.getDeviveListing()
    },
    // 重置 fun
    resetForm () {
      this.FindFromForDevice.kw = ''
    },
    // 设备分配
    closeFrame () {
      this.isShowFrame = false
      this.seeChangeCourse = this.isShowFrame
      sessionStorage.setItem('checkedLeftArray', JSON.stringify([]))
      sessionStorage.setItem('checkedRightArray', JSON.stringify([]))
      this.$router.push(-1)
    }
  }
}
</script>
<style lang='scss' scoped>
  //@import url(); 引入公共css类
.outsideBox {
  width: 100%;
  height: 100%;
}
.likeBox {
  width: 98%;
  height: 80vh;
  padding: 10px 1%;
}
</style>
